<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return=array();
	exi($return);
}
if($_RQ['op']=='getfangan'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['keyword']){		
			$params['title like']='%'.trim($_RQ['keyword']).'%';
			$return['params']['title']=$_RQ['keyword'];	
	}
	if($_RQ['groupid']){
		$params['groupid']=intval($_RQ['groupid']);
	}
	if($_RQ['plugintype']){
		$params['plugin']=$_RQ['plugintype'];
	}
	//按点赞数排序作品
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_merch_game_fangan',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['image']=tomedia($item['image']);
			$item['plugintitle']=$this->tplgames2[$item['plugin']];
			$item['grouptitle']=pdo_getcolumn('jy_merch_category',array('id'=>$item['groupid'],'uniacid'=>$_SESSION['uniacid']),'catename');
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		}
	}else{
        $list='none';
    }
	exi($list);
}
if($_RQ['op']=='gettanmus'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['pid']){
		$params['pid']=intval($_RQ['pid']);
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$fields=array('id','mid','pid');
	$list=pdo_getslice('jy_merch_game_looklog',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	foreach($list as &$item){
		$member=cfc('core')->member_show($item['mid']);
		$member['nickname']=mb_substr($member['nickname'],0,4,'utf-8').'***';
		$item['nickname']=$member['nickname'];
		$member['avatar']=$member['avatar']?:'../core/resource/images/nopic.jpg';
		$item['avatar']=tomedia($member['avatar']);
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='getprovince'){
	$res=array('province'=>cfc('tools')->pcd());
	exi($res);
}
if($_RQ['op']=='getgoodsdetail'){
	$return=$this->model('goods_item')->get_goodsitem($return);
	exi($return);
}
//获取地址
if($_RQ['op']=='get_addresslist'){
	if($return['shopset']['addressdiyform']){
		$addressdiyform=pdo_getcolumn('jy_weishop_diyform_temp',array('id'=>$return['shopset']['addressdiyform'],'uniacid'=>$_SESSION['uniacid']),'diyformfields');
		$addressdiyform=$addressdiyform?json_decode($addressdiyform,true):array();
	}
	$return['list']=pdo_getall('core_address',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	foreach($return['list'] as &$av){
		$av['pcd']=json_decode($av['pcd'],true);
		$av['diyfields']=$av['diyfields']?json_decode($av['diyfields'],true):$addressdiyform;
	}
	exi($return);
}
?>